<!-- 报告审核列表 -->
<template>
	<view>
		<view class="" v-for="(item,index) in dataSource" :key="index">
			<view class="basic_box" v-if="index === 0" id="showPageReport">
				<view class="label">
					<view class="label_title">单据编号</view>
					<view class="label_info">{{item.billNo!==null?item.billNo:'--'}}</view>
				</view>
				<view class="flex_box">
					<view class="label">
						<view class="label_title">申请人</view>
						<view class="label_info">{{item.handlerId_dictText!==null?item.handlerId_dictText:'--'}}</view>
					</view>
					<view class="label">
						<view class="label_title">申请部门</view>
						<view class="label_info">{{item.handlerDeptId_dictText!==null?item.handlerDeptId_dictText:'--'}}</view>
					</view>
				</view>
				<view class="label">
					<view class="label_title">项目名称</view>
					<view class="label_info">{{item.projectId_dictText!==null?item.projectId_dictText:'--'}}</view>
				</view>
				<view class="flex_box">
					<view class="label">
						<view class="label_title">项目负责人</view>
						<view class="label_info">{{item.projectLeading_dictText!==null?item.projectLeading_dictText:'--'}}</view>
					</view>
				</view>
				<view class="label">
					<view class="label_title">生产团队</view>
					<view class="label_info">{{item.productTeam_dictText!==null?item.productTeam_dictText:'--'}}</view>
				</view>
				<view class="label">
					<view class="label_title">实施部门</view>
					<view class="label_info">{{item.executeDepart_dictText!==null?item.executeDepart_dictText:'--'}}</view>
				</view>
				<view class="label">
					<view class="label_title">签订单位</view>
					<view class="label_info">{{item.signUnit_dictText!==null?item.signUnit_dictText:'--'}}</view>
				</view>
				<view class="label">
					<view class="label_title">业务名称</view>
					<view class="label_info">{{item.categoryName!==null?item.categoryName:'--'}}</view>
				</view>
				<view class="flex_box">
					<view class="label">
						<view class="label_title">流程状态</view>
						<view class="label_info">{{item.bpmStatus_dictText!==null?item.bpmStatus_dictText:'--'}}</view>
					</view>
				</view>
			</view>
			<u-line color="#F2F2F2" v-if="index == 0"></u-line>
			<view class="collapse_content" v-else :style="{ maxHeight: isShowPage?maxHeight + 'px':0 }">
				<view class="basic_box" >
					<view class="label">
						<view class="label_title">单据编号</view>
						<view class="label_info">{{item.billNo!==null?item.billNo:'--'}}</view>
					</view>
					<view class="label">
						<view class="label_title">项目名称</view>
						<view class="label_info">{{item.projectName!==null?item.projectName:'--'}}</view>
					</view>
					<view class="label">
						<view class="label_title">经营团队</view>
						<view class="label_info">{{item.signteamName!==null?item.signteamName:'--'}}</view>
					</view>
					<view class="flex_box">
						<view class="label">
							<view class="label_title">项目承接人</view>
							<view class="label_info">{{item.undertakerName!==null?item.undertakerName:'--'}}</view>
						</view>
						<view class="label">
							<view class="label_title">预计合同额(元)</view>
							<view class="label_info">{{item.estimatedContractAmount!==null?item.estimatedContractAmount:'--'}}</view>
						</view>
					</view>
					<view class="label">
						<view class="label_title">业务分类</view>
						<view class="label_info">{{item.categoryName!==null?item.categoryName:'--'}}</view>
					</view>
					<view class="flex_box">
						<view class="label">
							<view class="label_title">合同占比(%)</view>
							<view class="label_info">{{item.contractRate!==null?item.contractRate:'--'}}</view>
						</view>
						<view class="label">
							<view class="label_title">合同分配额(元)</view>
							<view class="label_info">{{item.contractAmount!==null?item.contractAmount:'--'}}</view>
						</view>
					</view>
					<view class="label">
						<view class="label_title">生产团队</view>
						<view class="label_info">{{item.productTeam_dictText!==null?item.productTeam_dictText:'--'}}</view>
					</view>
					<view class="flex_box">
						<view class="label">
							<view class="label_title">需分配合同额(元)</view>
							<view class="label_info">{{item.separateContractAmount!==null?item.separateContractAmount:'--'}}</view>
						</view>
						<view class="label">
							<view class="label_title">流程状态</view>
							<view class="label_info">{{item.bpmStatus_dictText!==null?item.bpmStatus_dictText:'--'}}</view>
						</view>
					</view>
					<u-line color="#F2F2F2" v-if="index < dataSource.length-1"></u-line>
				</view>
			</view>
		</view>
		<u-empty
			v-if="!dataSource || !dataSource.length"
			style="width: 750rpx; padding-bottom: 20rpx;background-color: #ffffff;"
			mode="data"
			icon="/static/empty/data.png"
		></u-empty>
		<view class="btn" @click="counterTrial" v-if="dataSource && dataSource.length>1">{{isShowPage?'收起': '展开'}}</view>
	</view>
</template>

<script>
	import { filterMultiDictText, initDictOptions } from '@/utils/JDictSelectUtil.js'
	import tooltip from '@/uni_modules/uni-tooltip/components/uni-tooltip/uni-tooltip.vue'
	import fileList from '@/pages/synergy/components/fileList.vue'
	export default {
		name: 'reportAuditFormListItem',
		components: {
			tooltip,
			fileList
		},
		props: {
			dataSource: {
			  type: [Array],
			  default: () => [],
			},
		},
		data() {
			return {
				isShowPage: false, // 是否展示所有数据
				maxHeight: 0,
				filterMultiDictText,
				initDictOptions,
				dictOptions: {}
			}
		},
		watch: {
			dataSource: {
				handler (val) {
					// 当有大于一条数据时
					if (val && val.length>1) {
						this.timer = setTimeout(() => {
							clearTimeout(this.timer)
							this.timer = null
							this.$nextTick(() => {
								uni.createSelectorQuery().select('#showPageReport').boundingClientRect(data => {
									this.maxHeight = (data.height + 30)* (val.length - 1)
								}).exec();
							})
						}, 300)
					}
				},
				immediate: true
			}
		},
		created() {
			// this.initDictConfig()
		},
		methods: {
			counterTrial () {
				this.isShowPage = !this.isShowPage
			},
			//字典
			async initDictConfig() {
				initDictOptions('erp_employee_file,name,id').then(async (res) => {
					if (res.success) {
						this.$set(this.dictOptions, 'projectMember', res.result)
					}
				})
			},
			// 点击查看关联收款单
			handlerPaymentEdit (item) {
				this.$emit('clickPayment', item)
			},
			
		}
	}
</script>

<style scoped lang="less">
	
	.basic_box {
		padding: 20rpx 32rpx;
		box-sizing: border-box;
		background-color: #FFFFFF;
	}
	.label {
		margin-bottom: 20rpx;
		flex: 1;
	}
	
	.label_image{
		width: 320rpx;
		height: 180rpx;
		border-radius: 10rpx;
	}
	
	.label_title {
		font-size: 14px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #B2B2B2;
		height: 20px;
		margin-right: 16rpx;
	}
	
	.label_info {
		font-size: 14px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #171717;
	}
	.label_code{
		font-size: 14px;
		font-family: PingFangSC-Light, PingFang SC;
		font-weight: 300;
		color: rgba(0,0,0,0.9);
	}
	
	.label_num {
		font-size: 14px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #1E6FFF;
	}
	
	.flex_box {
		display: flex;
	}
	.btn{
		border-top: 1px solid rgba(0, 0, 0, 0.1);
		width: 750rpx;
		height: 41px;
		background: #FFFFFF;
		border-radius: 2rpx;
		font-size: 14px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #1E6FFF;
		line-height: 40px;
		text-align: center;
	}
	
	.collapse_content {
		transition: max-height .4s ease-in-out, -webkit-transform .4s ease-in-out, transform .4s ease-in-out;
		transform-origin: 50% 50% 0px;
		overflow: hidden;
	}
</style>